<script>
	import {
		mapState
	} from 'vuex';
	export default {
		// 此处globalData为了演示其作用，不是uView框架的一部分
		globalData: {},
		onLaunch(options) {
			// console.log('options.sceneoptions.sceneoptions.sceneoptions.sceneoptions.sceneoptions.scene');
			// console.log(options)
			this.$u.vuex('vuex_scene', options.scene);
			if (options.query.sale) {
				this.$u.vuex('vuex_sale', options.query.sale);
				console.log('真的值') ;
				console.log(this.vuex_sale) ;
			} ;
			// 获取用户地理信息
			this.get_address();
			this.$isResolve();
			this.getSystemInfo();
			// 如果登陆了应当获取用户信息
			this.getUserInfo();
		},
		methods: {
			getUserInfo() {
				if (this.vuex_hasLogin) {
					this.$u.api.getUserInfo({}).then(res => {
						this.$u.vuex('vuex_userInfo', res.info);
					})
				}
			},
			getSystemInfo() {
				// 获取设备信息
				uni.getSystemInfo({
					success: res => {
						this.$u.vuex('vuex_systemInfo', res);
					},
					fail: () => {
						this.$u.vuex('vuex_systemInfo', false);
					}
				});
			},
			async get_address() {
				let location = await uni.getLocation({
					type: 'wgs84',
				});
				if (location[1]) {
					this.$u.vuex('vuex_location', location[1]);
				}
			}
		},
		computed: {
			...mapState({
				vuex_hasLogin: state => state.vuex_hasLogin,
			})
		}
	}
</script>

<style lang="scss">
	@import "uview-ui/index.scss";
	// @import "common/demo.scss";
</style>
